home *** CD-ROM | disk | FTP | other *** search
/ Aminet 6 / Aminet 6 - June 1995.iso / Aminet / util / blank / bserver_v14.lha / BServer_v1.4 / Sources.lha / Sources / clients / StarField.c < prev   
Encoding:
C/C++ Source or Header  |  1995-03-23  |  3.0 KB  |  139 lines

  1. ;/*
  2. sc RESOPT IGNORE=73 DATA=NEAR NMINC UCHAR CONSTLIB STREQ STRMERGE NOSTKCHK NOSTDIO OPTIMIZE OPTSIZE StarField.c
  3. slink from LIB:c.o StarField.o to //Clients/StarField LIB LIB:sc.lib LIB:amiga.lib /lib/client.lib SC SD NOICONS STRIPDEBUG
  4. delete starfield.o
  5. quit
  6.  
  7.  StarField 1.2  (Client for BServer)
  8.  
  9.  Copyright © 1994-1995 by Stefano Reksten of 3AM - The Three Amigos!!!
  10.  All rights reserved.
  11. */
  12.  
  13. #include <exec/types.h>
  14. #include <intuition/intuition.h>
  15.  
  16. #include <proto/exec.h>
  17. #include <proto/intuition.h>
  18. #include <proto/graphics.h>
  19. #include <clib/alib_protos.h>
  20.  
  21. #include "/include/client.h"
  22.  
  23. char *ver = "$VER: StarField 1.2 "__AMIGADATE__;
  24.  
  25. struct IntuitionBase *IntuitionBase;
  26. struct GfxBase *GfxBase;
  27.  
  28. struct DisplayIDInformation *dinfo;
  29.  
  30. struct Screen *scr;
  31.  
  32. UWORD Stars[512][2];
  33.  
  34.  
  35. void DrawStars( void )
  36. {
  37. UWORD n, tmpx, trnd, swidth, sheight;
  38. struct Rectangle *rect;
  39. register PLANEPTR plane0, plane1;
  40. register UWORD last_star;
  41. UBYTE brightness, color;
  42.  
  43. rect = GETTXTOSCANRECT(dinfo);
  44.  
  45. swidth = RECTANGLEWIDTH(rect);
  46. sheight = RECTANGLEHEIGHT(rect);
  47. brightness = GETBRIGHTNESS(dinfo);
  48.  
  49. if ( DISPLAYID( dinfo ) & LACE )
  50.     last_star = ( sheight > 512 ? 512 : sheight );
  51. else
  52.     last_star = ( sheight > 256 ? 256 : sheight );
  53.  
  54. swidth = (swidth>>8)<<8;
  55.  
  56. if ( scr = OpenScreenTags( NULL,
  57.     SA_DisplayID, DISPLAYID( dinfo ),
  58.     SA_Width, swidth,
  59.     SA_Height, sheight,
  60.     SA_Left, (RECTANGLEWIDTH(rect) - swidth)/2,
  61.     SA_Top, 0,
  62.     SA_Depth, 2,
  63.     SA_Overscan, OSCAN_TEXT,
  64.     SA_Type, CUSTOMSCREEN,
  65.     SA_Quiet, TRUE,
  66.     TAG_END ) )
  67.     {
  68.     register struct ViewPort *vp = &(scr->ViewPort);
  69.  
  70.     SpritesOff();
  71.  
  72.     SetRGB4( vp, 0, 0, 0, 0 );
  73.     color = 5*brightness/100;
  74.     SetRGB4( vp, 1, color, color, color );
  75.     color = 10*brightness/100;
  76.     SetRGB4( vp, 2, color, color, color );
  77.     color = 15*brightness/100;
  78.     SetRGB4( vp, 3, color, color, color );
  79.  
  80.     for ( n = 0; n < last_star; n++ )
  81.         {
  82.         Stars[n][0] = RangeRand(swidth-1);
  83.         Stars[n][1] = RangeRand( 7 );
  84.         }
  85.  
  86.     while( STILL_BLANKING )
  87.         {
  88.         /* Draw stars */
  89.         plane0 = scr->RastPort.BitMap->Planes[0];
  90.         plane1 = scr->RastPort.BitMap->Planes[1];
  91.  
  92.         WaitTOF();
  93.         for ( n = 0; n < last_star; n++ )
  94.             {
  95.             * (plane0 + (Stars[n][0]>>3) ) = 0;
  96.             * (plane1 + (Stars[n][0]>>3) ) = 0;
  97.  
  98.             tmpx = Stars[n][0] + Stars[n][1];
  99.             if ( tmpx >= swidth )
  100.                 {
  101.                 while ( !(trnd = RangeRand( 7 ) ) );
  102.                 Stars[n][0] = 0;
  103.                 Stars[n][1] = trnd;
  104.                 }
  105.             else    Stars[n][0] = tmpx;
  106.  
  107.             if ( Stars[n][1]>>1 & 1 )
  108.                 * (plane0 + (Stars[n][0]>>3) ) = 128>>(Stars[n][0] & 7);
  109.             if ( Stars[n][1]>>1 & 2 )
  110.                 * (plane1 + (Stars[n][0]>>3) ) = 128>>(Stars[n][0] & 7);
  111.  
  112.             plane0 += swidth >>3;
  113.             plane1 += swidth >>3;
  114.             }
  115.         }
  116.     CloseScreen( scr );
  117.     SpritesOn();
  118.     }
  119. else
  120.     SendClientMsg( ACTION_FAILED );
  121. }
  122.  
  123. void __main( char *line )
  124. {
  125. if ( IntuitionBase = (struct IntuitionBase *)OpenLibrary( "intuition.library", 37L ) )
  126.     {
  127.     if ( GfxBase = (struct GfxBase *)OpenLibrary( "graphics.library", 37L ) )
  128.         {
  129.         if ( dinfo = OpenCommunication() )
  130.             {
  131.             DrawStars();
  132.             CloseCommunication( dinfo );
  133.             }
  134.         CloseLibrary( (struct Library *)GfxBase );
  135.         }
  136.     CloseLibrary( (struct Library *)IntuitionBase );
  137.     }
  138. }
  139.